package top.yekongle.shop.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.yekongle.shop.dao.SysUserRepository;
import top.yekongle.shop.entity.SysUser;

import java.util.List;

/**
 * @author Hank Lau
 * @date 2022/5/2
 */
@Api(tags = "User 用户相关接口")
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {
	private final SysUserRepository userRepository;

	@ApiOperation("新增用户接口")
 	@PostMapping("/add")
//	@ApiImplicitParams({
//			@ApiImplicitParam(name = "name", value = "名字", dataType = "String", required = true),
//			@ApiImplicitParam(name = "typeId", value = "类型ID", dataType = "Long", required = true)
//	})
 	public boolean addUser(@RequestBody SysUser user){
 		return true;
 	}

	@ApiOperation("查询用户接口")
	@GetMapping("/getAll")
	public List<SysUser> getAll(){
//		List<User> list = new ArrayList<User>();
//		for (int i = 0; i < 100; i++){
//			User user= new User( );
//			user.setId(i + 1);
//			user.setName("Java" + i);
//			user.setPassword("1234qwer" );
//			list.add(user);
//		}
//		return list;
		return userRepository.getAll();
	}
}
